home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 26.zip
/
BS1 part 26
/
The Director Toolkit v1.0.adf
/
BlitUtil
/
ebuscript
< prev
next >
Wrap
Text File
|
1987-02-25
|
33KB
|
1,183 lines
rem enhanced blit utility
rem Copyright 1988, Right Answers, All Rights Reserved
rem This script is provided for educational purposes or
rem ehancement by the original Director ToolKit owner only.
rem no part of this script or it's .film file are to
rem be distributed.
rem NOTE: if you decide to modify or re-run this script through
rem the Director for some reason, note that it is designed to be run
rem from an ASSIGNIT icon, which assigns HERE: to the current directory.
rem When you run the Director directly on this script, the HERE: will
rem have not been assigned, and you will get an error. However, the
rem .film file will have then been correctly generated, and you
rem will then be able to run the Enhanced Blit Utility from the
rem CLI by typing the name of the ASSIGNIT program (EBU) or clicking
rem on it's icon as usual. The changes you have made will have taken
rem effect. When working on scripts that are designed to be run from
rem the ASSIGNIT program, it can be helpful to assign HERE: to your
rem working Directory.
rem The following values are used in determining the screen centering
rem 127,43 are correct for NTSC, PAL screens should be 127,??
rem make the Y number larger to move the screen down, smaller to
rem move up. You could also adjust these to compensate for
rem "morerows" adjusted preferences.
ScreenX=127
ScreenY=43 :rem adjust this for PAL centering
NormHt=200
setblack 1
rem *** important routine names ***
menua=1000:checkbot=2000:getbuff=3000:getfile=4000:strend=5000
fileout=6000:yesno=5010:getbrush=7000:chkmain=2100
genblit=7100:genmove=7200:genchar=7300:centscr=7400
placbrsh=7500:outblit=7600:putbrush=7700:initfils=7800
saveobj=7900:doread=8000:errmsg=8100
fnamesz=100
charsiz=7 :rem preserve char blit parameters, x,y,x,y,w,h etc.
totchars=50 :rem max number of character frames allowed
totfiles=20 :rem number of remembered object files
filentsz=fnamesz+2 :rem buffer #, used flag, filename
rem array locations
tname=0
bkgname=tname+fnamesz
objname=bkgname+fnamesz
outname=objname+fnamesz
postfix=outname+fnamesz+1
temp=postfix+fnamesz-1
title=temp
quote=temp+fnamesz
filent=quote+4
charbase=filent+filentsz*totfiles
charbend=charbase+charsiz*totchars
array charbend+1,2
mode=0:open mode,"here:screeny"
if mode
read mode,$(0),20
NormHt=$(0)
read mode,$(0),20
ScreenY=$(0)
close
endif
gosub initfils :rem initialize remembered object files
rem file req is assumed to have been put in ram by the ASSIGNIT icon.
mode=0
open mode,"ram:filereq"
close
if mode=0
print "Error: Can't find file 'filereq'"
end
endif
rem variable initializations
transon=0 :rem blit transparent flag
conton=0 :rem continuous move flag
btype=0 :rem blit/diss/wipe type flag
firstmv=1 :rem move counter
cancel=0
brselect=0
charf=0
helpa=0
oback=0
appmode=0
overscan=0
firstopn=1
newback=1
fname=0:space=32:colon=58:slash=47
aspeed=0
@(quote)=34
@(quote+1)=0
string "ram:ebuout",$(outname)
@(bkgname)=0:@(objname)=0:@(postfix)=0:@(postfix-1)=colon
savebuff=10:screen=1:bkgbuf=0:objbuf=0:altbuf=4:objused=0
load screen,"here:buscreen1"
load savebuff,"here:buscreen2"
display savebuff:free screen
abort 0
blits=0:moves=0:obuff=3:bbuff=1
gosub menua
abort 1
pointer 1
10 pause 10:goto 10
rem menua:
1000
new screen,savebuff
copy savebuff,screen
display screen:gosub centscr
pen 1,1:rect 137,174,256,194 :rem clear stuff
setblack 0
1001
blit savebuff,0,0,0,0,320,112 :rem restore upper screen
gosub 1100 :rem restore lower screen
getmouse xm,ym
gosub checkbot
gosub chkmain
goto 1001 :rem redisplay
rem redisplay lower screen
1100
pen 1,1
rect 8,126,311,134
rect 8,150,311,158
rect 118,162,311,172
pen 0,1:pen 1,2:center 0:drawmode 1
move 67,183:text blits;
if blits=0:text " ";:endif
move 67,192:text moves;
if moves=0:text " ";:endif
center 1:pen 1,3
move 0,133:if @(bkgname):text $(bkgname):else:text "none";:endif
move 0,157:if @(objname):text $(objname):else:text "none";:endif
margins 118,311:move 0,170:text $(outname)
margins -1,-1:center 0
move 276,122:text bbuff;" ";
move 276,146:text obuff;" ";
move 93,183
if appmode
text "*";
else
text " ";
endif
return
rem checkbot:
2000
center 0
if ym<113:return:endif
if ym>177 & ym<191 & xm>259 & xm<312 :rem done signaled
if firstmv#1
gosub fileout
write
write " goto 10 :rem end of text generated by BLITUTIL"
write
close
endif
if fname:execute a,"c:delete ram:fname":endif
end
endif
if ym<136
if ym < 125 & xm > 208
by=122:gosub getbuff
else
string "Load Background Image",$(title)
name=bkgname:t=0
if @(name)=0:string $(objname),$(bkgname):t=1:endif
gosub getfile:if t & fname=0:@(name)=0:endif
if fname
bkgbuf=2
free bkgbuf
load bkgbuf,$(bkgname)
newback=1
endif
endif
return
endif
if ym<160
if ym < 149 & xm > 208
by=146:gosub getbuff
else
if objused
gosub saveobj
endif
brselect=0
string "Load Object Image",$(title)
name=objname:t=0
if @(name)=0:string $(bkgname),$(objname):t=1:endif
gosub getfile:if t & fname=0:@(name)=0:endif
if fname
objbuf=3
free objbuf
load objbuf,$(objname)
j=1
for i=0 to totfiles-1
compare v,$(objname),$(filent+i*filentsz+2)
if v:j=0:obuff=@(filent+i*filentsz):endif
next
if j
rem pick new obj buff
2007 i=0
2008 if i#totfiles
j=filent+i*filentsz
if @(j)=obuff
obuff=obuff+1
goto 2007 :rem found it, start over
endif
i=i+1
goto 2008
endif
endif
endif
endif
return
endif
if ym<173
2001 pen 1,1:rect 118,162,311,172
pen 1,3:move 118,170:input $(outname),50
if @(outname)=0:goto 2001:endif
return
endif
if ym>176 & ym<184 & xm>101 & xm<134 :rem append button
appmode=1-appmode
return
endif
if ym>186 & ym<194 & xm>101 & xm<134 :rem clear button
blit savebuff,137,174,137,174,120,22 :rem get xtra buttons
gosub yesno
pen 1,1:rect 137,174,256,194 :rem clear stuff when done
if choice
mode=1:open mode,$(outname):close:moves=0:blits=0
endif
endif
return
rem chkmain -- check upper buttons
2100
if ym>112:return:endif :rem not upper buttons
if xm>27 & xm<293 & ym>56 & ym<74 :rem blit/dissolve/wipe
goto genblit
endif
if xm>27 & xm<293 & ym>74 & ym<90 :rem move object
goto genmove
endif
if xm>27 & xm<293 & ym>90 & ym<106 :rem gen a character
goto genchar
endif
return
rem getbuff - get new buffer number
3000
move 276,by
pen 0,1:pen 1,3
input $(temp),3
move 276,by
if by=122
bbuff=$(temp)
text bbuff;" ";
else
obuff=$(temp)
text obuff;" ";
endif
return
rem getfile
rem returns file name in $(name), must be initialized with either
rem @(name)=0, or with default file name
rem gets requester title from $(title), $(title) must have space
rem for 100 characters max.
rem uses strend routine (5000) to find end of strings
4000
strend=5000
rem build file requester command, putting quotes around text
string $(title),$(title+50)
string "ram:filereq ",$(title)
@(title+12)=@(quote)
string $(title+50),$(title+13)
se=title+13:gosub strend
@(se)=@(quote)
if @(name) :rem preserve last directory
@(se+1)=space
@(se+2)=@(quote)
string $(name),$(se+3)
gosub strend
rem backup to find : or /
4001 if @(se)#colon & @(se)#slash:se=se-1:goto 4001:endif
if @(se)=colon:se=se+1:endif
@(se)=@(quote)
endif
@(se+1)=0 :rem terminate string
execute a,$(title)
mode=0:open mode,"ram:fname":fname=mode
if mode
read a,$(name),98
close
endif
return
rem strend
5000 if @(se):se=se+1:goto 5000:endif
return
rem yesno
5010
getmouse xm,ym
if xm>238 & xm<254 & ym>176 & ym<184
choice=1
return
endif
if xm>238 & xm<254 & ym>186 & ym<194
choice=0
return
endif
rem flash y/n
blitmode 102
blit savebuff,137,7,239,177,15,17:pause 1
blit savebuff,137,7,239,177,15,17
blitmode -1
goto 5010
return
rem fileout
6000
mode=0:open mode,$(outname)
close
if mode
if firstopn & appmode=0:mode=1:else:mode=2:endif
open mode,$(outname)
if mode=0
print " Can't open output file ";$(outname)
end
endif
seek -1
else
mode=1:open mode,$(outname)
if mode=0
print " Can't open output file ";$(outname)
end
endif
endif
firstopn=0
return
rem getbrush -- cutout a box
7000
rem pop up file requester if no objbuf...
cancel=0 :rem just in case
if objbuf=0:xm=147:ym=151:gosub 2000:endif
if objbuf=0:cancel=1:return:endif
display objbuf:gosub centscr
pen 1,31
drawmode 2 :rem xor mode
getmouse x,y
xa=x:ya=y
move x+10,y:draw x,y:draw x,y+10
getmouse xb,yb
move x+10,y:draw x,y:draw x,y+10
if xb<x:xa=xb:xb=x:endif
if yb<y:ya=yb:yb=y:endif
pointer 1
7087 :rem draw box
move xa,ya:draw xa,yb:draw xb,yb:draw xb,ya:draw xa,ya
7088
pause 1:ifkey char:if char=13|char=32:goto 7089:endif
ifmouse xt,yt:if xt=-1:goto 7088:endif
rem erase box
move xa,ya:draw xa,yb:draw xb,yb:draw xb,ya:draw xa,ya
if !(xt-xa)+!(yt-ya) > !(xt-xb)+!(yt-yb):xb=xt:yb=yt
else:xa=xt:ya=yt:endif
goto 7087
7089
pointer 0
rem erase box
move xa,ya:draw xa,yb:draw xb,yb:draw xb,ya:draw xa,ya
drawmode -1
x=xa:y=ya
if xb<x:xa=xb:xb=x:endif
if yb<y:ya=yb:yb=y:endif
wid=xb-xa:hite=yb-ya
return
rem genblit
7100
gosub 1100 :rem redisplay lower screen
pen 1,1:rect 8,57,312,106 :rem erase upper buttons
blit savebuff,137,177,8,74,99,16:rect 10,76,104,87 :rem dissolve
blit savebuff,137,177,111,74,99,16:rect 113,76,207,87 :rem blit
blit savebuff,137,177,214,74,99,16:rect 216,76,310,87 :rem wipe
blit savebuff,137,177,8,57,99,16:rect 10,59,104,70 :rem main
blit savebuff,137,177,111,57,99,16:rect 113,59,207,70 :rem pick
blit savebuff,137,177,214,57,99,16:rect 216,59,310,70 :rem transp
pen 1,0
center 1
if brselect:pen 1,0:else:pen 1,1:endif :rem deselect buttons if no brsh
margins 10,104:move 0,85:text "DISSOLVE"
margins 113,207:move 0,85:text "BLIT"
margins 216,310:move 0,85:text "WIPE"
pen 1,0
margins 113,207:move 0,67:text "PICK OBJECT"
margins 10,104:move 0,67:text "Main Menu"
margins -1,-1:center 0:move 12,106:text "Postfix: ";
pen 1,1:rect 84,90,314,108 :rem erase old postfix
pen 1,3
if @(postfix)
text $(postfix);
else
text "none";
endif
7101
center 1
margins 216,310:move 0,67
if transon:pen 1,3:else:pen 1,0:endif
text "TRANSPARENT"
margins -1,-1
getmouse xm,ym
gosub checkbot
x=xm:y=ym
if x>8 & y>74 & x<102 & y<89 :rem dissolve
btype=1
endif
if x>111 & y>74 & x<205 & y<89 :rem blit
btype=2
endif
if x>214 & y>74 & x<308 & y<89 :rem wipe
btype=3
endif
if x>8 & y>56 & x<102 & y<71 :rem back to main
pen 1,1:rect 8,57,312,106 :rem erase upper buttons
return
endif
if x>214 & y>56 & x<312 & y<71 :rem transparent toggle
transon=1-transon
goto 7101
endif
if x>111 & y>56 & x<205 & y<71 :rem pick object
gosub getbrush :rem cutout a brush
display screen:gosub centscr
gosub 1100 :rem redisplay lower screen
if cancel=0:brselect=1:goto 7100:endif
goto 7101
endif
if y>90 & y<108
pen 1,1:rect 84,90,314,108 :rem erase old postfix
pen 1,3:move 85,106:input $(postfix),40
endif
if btype=0:goto 7100:endif
if brselect=0:goto 7200:endif :rem no brush selected
rem gen blit command
rem first, get brush
outflag=1 :rem flag write out blits directly
gosub putbrush :rem place down a brush
btype=0
goto 7100 :rem for more
rem putbrush
7700
rem now place on background
display objbuf:gosub centscr :rem insure we're on brush screen
free screen :rem we may need the space for second bkgrnd buff.
if outflag=2 & bkgbuf=0
bkgbuf=2
oback=1 :rem flag not real background buff
new bkgbuf,objbuf
endif
rem filerequest for bkground if nonexistant
if bkgbuf=0:xm=147:ym=130:gosub 2000:endif
cancel=0
if bkgbuf=0:cancel=1:goto 7799:endif
display bkgbuf:gosub centscr :rem here's where we go now...
overscan=os
rem swap stuff into fast memory if possible.....
memory all,chip,fast
if fast>50000
gotfast=1
newfast 11,savebuff
copy savebuff,11
free savebuff
else:gotfast=0:endif
gosub placbrsh
if cancel:goto 7798:endif
if outflag=0
firstxt=outxt
firstyt=outyt
gosub placbrsh :rem place in second pos.
if cancel:goto 7798:endif
endif
7798
rem restore buffers
if gotfast
new savebuff,11
copy 11,savebuff
free 11
endif
7799
if objbuf
new screen,savebuff
copy savebuff,screen
display screen:gosub centscr
pen 1,1:rect 137,174,256,194 :rem clear stuff
endif
return
rem genmove
7200
gosub 1100 :rem redisplay lower screen
pen 1,1:rect 8,57,312,106 :rem erase upper buttons
blit savebuff,137,177,8,57,99,16:rect 10,59,104,70 :rem main menu
blit savebuff,137,177,111,57,99,16:rect 113,59,207,70 :rem pick
blit savebuff,137,177,111,74,99,16:rect 113,76,207,87 :rem move
blit savebuff,137,177,214,57,99,16:rect 216,59,310,70 :rem transp
blit savebuff,137,177,8,74,99,16:rect 10,76,104,87 :rem load char
blit savebuff,137,177,214,74,99,16:rect 216,76,310,87 :rem cont.
pen 1,0
center 1
margins 10,104:move 0,67:text "Main Menu"
margins 113,207:move 0,67:text "PICK OBJECT"
margins 10,104:move 0,85:text "LOAD CHAR"
7201
if brselect:pen 1,0:else:pen 1,1:endif :rem deselect move if no brush
center 1
margins 113,207:move 0,85:text "MOVE"
margins 216,310:move 0,67
if transon:pen 1,3:else:pen 1,0:endif
text "TRANSPARENT"
margins 216,310:move 0,85
if conton:pen 1,3:else:pen 1,0:endif
text "CONTINUOUS"
margins -1,-1
getmouse xm,ym
gosub checkbot
x=xm:y=ym
if x>8 & y>56 & x<102 & y<71 :rem back to main
pen 1,1:rect 8,57,312,106 :rem erase upper buttons
return
endif
if x>214 & y>56 & x<312 & y<71 :rem transparent toggle
transon=1-transon
goto 7201
endif
if x>214 & y>74 & x<308 & y<89 :rem continuous toggle
conton=1-conton
goto 7201
endif
if x>111 & y>56 & x<205 & y<71 :rem pick object
gosub getbrush :rem cutout a brush
display screen:gosub centscr
gosub 1100 :rem redisplay lower screen
if cancel=0:brselect=1:endif
goto 7201
endif
if x>8 & y>74 & x<107 & y<90 :rem load char
string "Load Character",$(title)
name=tname:@(name)=0
gosub getfile
if fname
mode=0:open mode,$(tname)
if mode=0
string "Can't open save file",$(temp)
gosub errmsg
goto 7200
endif
gosub doread
if cancel:goto 7200:endif
compare t,"charsave",$(temp)
if t=0
string "Not a character file!!",$(temp)
gosub errmsg
goto 7200
endif
gosub initfils :rem clear filent table
gosub doread
if cancel:goto 7200:endif
obuff=$(temp)
gosub doread
if cancel:goto 7200:endif
string $(temp),$(objname)
i=0
7222 j=filent+i*filentsz
gosub doread
if cancel:goto 7200:endif
compare t,".",$(temp)
if t:goto 7223:endif
t=$(temp) :rem get buff
@(j)=t
gosub doread
if cancel:goto 7200:endif
string $(temp),$(j+2) :rem get name
i=i+1
goto 7222
7223 gosub doread
if cancel:goto 7200:endif
charf=$(temp) :rem get number of char entries
if charf=0
string "Empty character file!!",$(temp)
gosub errmsg
goto 7200
endif
for i=0 to charf-1
v=charbase+i*charsiz
for j=0 to charsiz-1
gosub doread
if cancel
j=999
i=charf
else
t=$(temp)
@(v+j)=t
endif
next
next
if j=999:goto 7200:endif :rem end of file too soon
close
t=charbase+(charf-1)*charsiz :rem locate last brush
obuff=@(t)
xa=@(t+1)
ya=@(t+2)
xoff=@(t+3)
yoff=@(t+4)
wid=@(t+5)
hite=@(t+6)
for i=0 to totfiles-1
j=filent+filentsz*i
if @(j)=obuff
string $(j+2),$(objname) :rem get last brush filename
i=totfiles
endif
next
objbuf=3
free objbuf
mode=0:open mode,$(objname)
if mode=0
string "Can't open ",$(temp)
@(temp+11)=10
string $(objname),$(temp+12)
gosub errmsg
goto 7200
endif
load objbuf,$(objname)
brselect=1
endif
goto 7200
endif
if 0=(x>111 & y>74 & x<205 & y<89) :rem not a move ?
goto 7200
endif
if brselect=0:goto 7201:endif :rem no brush selected
objused=1
gosub saveobj
rem make sure we've loaded a background
if bkgbuf=0:xm=147:ym=130:gosub 2000:endif
if helpa=0
pen 1,1:rect 8,57,312,106 :rem erase upper buttons
pen 0,1:pen 1,0
center 0:move 12,86:text "Select starting then ending location";
pause 20
helpa=1 :rem don't repeat this message
endif
outflag=0 :rem flag don't write out blits directly
gosub putbrush :rem place down a brush
if cancel:goto 7200:endif :rem bail out
rem now we have firstxt,firstyt,outxa,outya,outxt,outyt,outwid,outhite
7202
gosub 1100
pen 1,1:rect 8,57,312,106 :rem erase upper buttons
pen 0,1:pen 1,0
center 0:move 12,86:text "Number of frames to move?";
pen 1,3
input $(temp),10
if @(temp)=0:goto 7202:endif :rem don't accept return
steps = $(temp)
if steps=0:goto 7200:endif :rem no steps
7203
pen 1,1:rect 8,57,312,106 :rem erase upper buttons
pen 0,1:pen 1,0
center 0:move 12,86:text "Speed (0-? where 0 = fastest)?";
pen 1,3
input $(temp),10
if @(temp)=0:goto 7203:endif :rem don't accept return
aspeed = $(temp)
gosub fileout
rem ************************************ write out move
if firstmv=1
write
write " rem uses buffers 1 and 2 for double buffering"
write " rem requires 3 CHIP buffers plus one buffer for"
write " rem each object file required"
write " rem we will double buffer out of buffers 28 and 29"
write
write " setblack 1"
write " speed 1"
write " aspeed=";aspeed;" :rem adjust this to change speed"
endif
if newback
write
write " bkbuf=";bbuff;" :rem number of background buffer"
write " load bkbuf,";$(quote);$(bkgname);$(quote)
if overscan
write " position -1,-1 :rem adjust for overscan"
endif
newback=0 :rem mark written.
endif
for i=0 to totfiles-1 :rem write all object loads
j=filent+i*filentsz
if @(j) # -1 & @(j+1) = 0
write
write " objbuf=";@(j);" :rem number of object buffer"
write " load objbuf,";$(quote);$(j+2);$(quote)
@(j+1)=1 :rem mark written
endif
next
if firstmv=1
write
write " new 28,bkbuf"
write " new 29,bkbuf"
write " copy bkbuf,28"
write " copy bkbuf,29"
write
write " display 28"
write " fade 1,-1,0"
write
write " buff=29"
write " blitdest buff"
write " goto 10"
write
write "rem double buffer routine"
write "100 display buff"
write " display buff :rem to adjust timing for potential screen flash"
write " buff=57-buff"
write " blitdest buff"
write " copy bkbuf,buff :rem setup next background"
write " pause aspeed"
write " return"
write
write "10"
endif
write "rem ****** start of move #";firstmv;" ***********"
if transon:write " transparent 1":endif
if charf=0
write " objbuf=";obuff
write " objx=";outxa
write " objy=";outya
write " objw=";outwid
write " objh=";outhite
write " xs=";firstxt
write " ys=";firstyt
write " xe=";outxt
write " ye=";outyt
write " st=";steps
write " xd=xe-xs"
write " yd=ye-ys"
write
if conton
write " for si=0 to st-1 :rem -1 added by continuous"
else
write " for si=0 to st"
endif
write " blit objbuf,objx,objy,xs+xd*si/st,ys+yd*si/st,objw,objh"
write " gosub 100"
write " next"
else
xs=firstxt
ys=firstyt
xe=outxt
ye=outyt
xd=xe-xs
yd=ye-ys
c=0
ob=-9
for si=0 to steps
t=charbase+c*charsiz
if ob#@(t)
ob=@(t)
write " objbuf=";ob
endif
tx=xs+xd*si/steps
ty=ys+yd*si/steps
tx=tx+(@(t+3)-xoff)
ty=ty+(@(t+4)-yoff)
write " blit objbuf,";@(t+1);",";@(t+2);",";tx;",";ty;",";@(t+5);",";@(t+6);":gosub 100"
c=c+1
if c=charf:c=0:endif
next
endif
if transon:write " transparent 0":endif
if conton
write " rem copy -1,bkbuf :rem command removed by continuous"
else
write " copy -1,bkbuf :rem make final position permanent"
endif
write
write "rem ****** end of move #";firstmv;" **************"
write
firstmv=firstmv+1
moves=moves+1
rem ************************************
close
goto 7200 :rem back for more
rem genchar
7300
gosub 1100 :rem redisplay lower screen
pen 1,1:rect 8,57,312,106 :rem erase upper buttons
blit savebuff,137,177,8,57,99,16:rect 10,59,104,70 :rem main menu
blit savebuff,137,177,111,57,99,16:rect 113,59,207,70 :rem pick
blit savebuff,137,177,111,74,99,16:rect 113,76,207,87 :rem add object
blit savebuff,137,177,8,74,99,16:rect 10,76,104,87 :rem new char
blit savebuff,137,177,214,57,99,16:rect 216,59,310,70 :rem transp
blit savebuff,137,177,214,74,99,16:rect 216,76,310,87 :rem del object
blit savebuff,137,177,214,91,99,16:rect 216,93,310,104 :rem save char
pen 1,0
center 1
margins 10,104:move 0,67:text "Main Menu"
move 0,85:text "NEW CHAR"
margins 113,207:move 0,67:text "PICK OBJECT"
margins 216,310:move 0,85:text "DEL OBJECT"
margins 216,310:move 0,102:text "SAVE CHAR"
7301
if brselect:pen 1,0:else:pen 1,1:endif :rem deselect add if no brush
center 1
margins 113,207:move 0,85:text "ADD OBJECT"
margins 216,310:move 0,67
if transon:pen 1,3:else:pen 1,0:endif
text "TRANSPARENT"
pen 1,0:margins -1,-1:center 0:move 12,102:text "Objects in char: ";
pen 1,2:text charf;" ";
getmouse xm,ym
gosub checkbot
x=xm:y=ym
if x>8 & y>56 & x<102 & y<71 :rem back to main
pen 1,1:rect 8,57,312,106 :rem erase upper buttons
return
endif
if x>8 & y>74 & x<102 & y<89 :rem new char
charf=0
gosub initfils :rem clear remembered files
goto 7301
endif
if x>214 & y>56 & x<312 & y<71 :rem transparent toggle
transon=1-transon
goto 7301
endif
if x>214 & y>74 & x<308 & y<89 :rem del object
if charf:charf=charf-1:endif
goto 7301
endif
if x>111 & y>56 & x<205 & y<71 :rem pick object
gosub getbrush :rem cutout a brush
display screen:gosub centscr
gosub 1100 :rem redisplay lower screen
if cancel=0:brselect=1:endif
goto 7301
endif
if x>214 & y>91 & x<313 & y<107 :rem save char
string "Save Character",$(title)
name=tname:@(name)=0
gosub getfile
if fname
if objused:gosub saveobj:endif
mode=1:open mode,$(tname)
if mode=0
string "Can't open save file",$(temp)
gosub errmsg
goto 7300
endif
write "charsave"
write obuff
write $(objname)
for i=0 to totfiles-1
j=filent+i*filentsz
if @(j)#-1
write @(j) :rem write buff
write $(j+2) :rem write name
endif
next
write "." :rem end of filent table
write charf :rem number of char entries
for i=0 to charf-1
t=charbase+i*charsiz
for j=0 to charsiz-1
write @(t+j)
next
next
close
endif
goto 7300
endif
if 0=(x>111 & y>74 & x<205 & y<89) :rem not add to char?
goto 7300
endif
if charf=totchars
string "Error: too many objects",$(temp)
gosub errmsg
goto 7300
endif
if charf=0
pen 1,1:rect 8,57,312,108 :rem erase upper buttons
pen 0,1:pen 1,0
center 0:move 12,86:text "Place object in working position"
pause 20
if bkgbuf :rem dump background if any...
free bkgbuf
bkgbuf=0
@(bkgname)=0
endif
endif
outflag=2 :rem flag don't write out blits directly
gosub putbrush :rem place down a brush
if cancel:goto 7300:endif :rem bail out
rem now we have outxa,outya,outxt,outyt,outwid,outhite
t=charbase+charf*charsiz
@(t)=obuff
@(t+1)=outxa
@(t+2)=outya
@(t+3)=outxt
@(t+4)=outyt
@(t+5)=outwid
@(t+6)=outhite
objused=1 :rem we used this buffer
xoff=outxt
yoff=outyt
charf=charf+1
goto 7300
rem centscr - center display for whatever size image we have.
7400
x=ScreenX
y=ScreenY
resolution -1,xres,yres,depth
if xres>639
x=x-(xres-640)/4
else
x=x-(xres-320)/2
endif
if yres>399
y=y-(yres-NormHt*2)/4
else
y=y-(yres-NormHt)/2
endif
position x,y
if x#127 | y#43:os=1:else:os=0:endif
return
rem placbrsh - place brush over background
7500
cancel=0
rem clone bkgbuf into altbuf
new altbuf,bkgbuf :rem this could still blow out in hires overscan
copy bkgbuf,altbuf
display altbuf :rem we'll modify this one
buff=bkgbuf
x=0:y=0
pointer 1
7588 display buff:buff=(bkgbuf+altbuf)-buff
pause 1
ifkey char
if char=13:goto 7589:endif :rem return
if char=32:goto 7586:endif :rem space (more)
if char=27:goto 7570:endif :rem escape (abort)
if char=-101:goto 7587:endif
ifmouse xt,yt:if xt=-1:goto 7588:endif
x=xt:y=yt
7580
display altbuf
copy bkgbuf,altbuf :rem erase old brush
if transon:transparent 1:endif
pen 0,0
blit objbuf,xa,ya,x,y,wid,hite
if transon:transparent 0:endif
goto 7588
rem abort
7570
cancel=1
goto 7571
rem all done
7589
copy altbuf,bkgbuf :rem preserve mods
7571
transparent -1
pointer 0
display bkgbuf
free altbuf
xt=x:yt=y
gosub outblit
return
rem new with same brush
7586
if outflag#1:goto 7589:endif :rem done if in move mode
copy altbuf,bkgbuf
xt=x:yt=y
gosub outblit
goto 7580
rem arrow key?
7587
getkey char
if char=67:x=x+1:goto 7580:endif
if char=68:x=x-1:goto 7580:endif
if char=66:y=y+1:goto 7580:endif
if char=65:y=y-1:goto 7580:endif
if char=84:y=y-10:goto 7580:endif
if char=83:y=y+10:goto 7580:endif
if char=32
getkey char
if char=65:x=x-10:endif
if char=64:x=x+10:endif
goto 7580
endif
goto 7588
rem outblit write blit command
7600
if outflag#1
outxa=xa:outya=ya:outxt=xt:outyt=yt:outwid=wid:outhite=hite
return
endif
gosub fileout :rem open output file
if @(postfix)=0:@(postfix-1)=0:endif
if btype=1
v=(wid*hite*depth)/128
write "DISSOLVE ";obuff;",";xa;",";ya;",";xt;",";yt;",";wid;",";hite;",";v;$(postfix-1)
endif
if btype=2
write "BLIT ";obuff;",";xa;",";ya;",";xt;",";yt;",";wid;",";hite;$(postfix-1)
endif
if btype=3
wpw=wid_hite
write "WIPE ";obuff;",";xa;",";ya;",";xt;",";yt;",";wid;",";hite;",";wpd;",";wpw;$(postfix-1)
endif
close
blits=blits+1
@(postfix-1)=colon
return
rem initfils
7800 for i=0 to totfiles-1
j=filent+filentsz*i
@(j)=-1 :rem mark empty
@(j+1)=0 :rem mark not written
next
return
rem saveobj
7900
i=0
7901 if i#totfiles
compare v,$(objname),$(filent+i*filentsz+2)
if v :rem already in list?
i=filent+i*filentsz
rem don't update buff if allready written out
if @(i+1)=0:@(i)=obuff:endif
goto 7909
return
endif
i=i+1
goto 7901
endif
i=0
7902 if i#totfiles
if @(filent+i*filentsz)#-1
i=i+1
goto 7902
endif
endif
i=filent+i*filentsz :rem beginning of filent
@(i)=obuff
string $(objname),$(i+2) :rem save filename
7909
return
rem diagnostic...
print "saveobj:"
for i=0 to totfiles-1
j=filent+i*filentsz
if @(j)#-1:print " obuff=";@(j);" ";$(j+2):endif
next
return
rem doread
8000
cancel=0
read t,$(temp),80
if t=-1
string "Save file error!!!",$(temp)
gosub errmsg
cancel=1
endif
return
rem errmsg
8100
pen 1,1:rect 8,57,312,108 :rem erase upper buttons
pen 0,1:pen 1,0
center 0:move 12,72
margins 12,308:text $(temp)
move 152,106:text "OK"
pen 1,2:move 145,110:draw 145,96:draw 173,96
pen 1,0:move 174,96:draw 174,110:draw 146,110
8101
getmouse x,y :rem await acknowledge
if x>145 & x<174 & y>96 & y<110
pen 1,1:rect 8,57,312,111:pen 1,0
margins -1,-1
return
else
rem flash ok
blitmode 102
blit savebuff,116,139,146,97,28,13:pause 1
blit savebuff,116,139,146,97,28,13
blitmode -1
goto 8101
endif